<template>
    <div class="bg_write printemp"
        v-loading="loading">
        <div v-html="this.base.print_template"></div>
    </div>

</template>
<script>
import { getLodop } from "@/assets/js/LodopFuncs.js";

export default {
  data() {
    return {
      options: [],
      selectedOptions: [],
      optionProps: {
        value: "t",
        label: "t",
        children: "z"
      },
      show: false,
      loading: false,
      dialogVisible: false,
      data: {
        province: "",
        city: "",
        area: "",
        town: ""
      },
      base: {
        id: "",
        print_template: ""
      },
      product_ar: [],
      other: []
    };
  },
  components: {},
  methods: {
    imgError(item) {
      if (!item) {
        return require("../../assets/img/default_head.png");
      }
      if (item.indexOf("http") >= 0) {
        return item;
      } else {
        return "/api/" + item;
      }
    },
    handleChange(value) {
      console.log(value);
      if (value) {
        for (var i = 0; i < value.length; i++) {
          console.log(value[i]);
          if (i == 0) this.base.mail_province = value[i];
          if (i == 1) this.base.mail_city = value[i];
          if (i == 2) this.base.mail_area = value[i];
          if (i == 3) this.base.mail_town = value[i];
        }
      }
    },
    showEditMailDialog() {
      this.dialogVisible = true;
    },
    getDetails(id) {
      console.log(id);
      var data = {};
      data["id"] = id;
      this.$api.getUser.getOrderPrintInfo(data).then(res => {
        this.base = res.data.result;
        console.log(this.base.print_template);
      });
    },
    addUpdate() {
      var data = {};
      data["id"] = this.base.id;
      data["pay_time"] = this.$fnc.phptime(this.base.pay_time);
      data["mail_time"] = this.$fnc.phptime(this.base.mail_time);
      data["complete_time"] = this.$fnc.phptime(this.base.complete_time);
      data["is_pay"] = this.base.is_pay;
      data["remark"] = this.base.remark;
      data["admin_remark"] = this.base.admin_remark;
      this.$api.getUser.updateOrderInfo(data).then(res => {
        if (res.data.status == 1 && res.data.code == 200) {
          this.$fnc.alertSuccess({ text: "提交成功" });
          this.visible = false;
        } else {
          this.$fnc.alertError(res.data.code_desc, res.data.result);
        }
      });
    },
    subForm() {
      var data = {};
      data["id"] = this.base.id;
      data["mail_name"] = this.base.mail_name;
      data["mail_tel"] = this.base.mail_tel;
      data["mail_province"] = this.base.mail_province;
      data["mail_city"] = this.base.mail_city;
      data["mail_area"] = this.base.mail_area;
      data["mail_town"] = this.base.mail_town;
      data["mail_address"] = this.base.mail_address;
      data["admin_remark"] = this.base.admin_remark;

      this.$api.getUser.getEditMail(data).then(res => {
        if (res.data.status == 1 && res.data.code == 200) {
          this.$fnc.alertSuccess({ text: "修改成功" });
          this.visible = false;
        } else {
          this.$fnc.alertError(res.data.code_desc, res.data.result);
        }
      });
    }
  },

  beforeCreate() {
    this.loading = true; //数据未加载之前调用loading
  },
  created() {
    this.loading = false;
    let LODOP = getLodop(); //调用getLodop获取LODOP对象
    if (!LODOP) {
      // undefined
      this.$message.error("打印插件未安装，请先下载");
    } else {
      console.log(2);
      LODOP.PRINT_INIT("");
      // var strBASE64Code=this.logoValue;
      // LODOP.PRINT_INIT("打印插件功能演示_Lodop功能_BASE64编码串打印图片");
      // LODOP.ADD_PRINT_IMAGE(50,60,"100%","100%",strBASE64Code);
      // LODOP.ADD_PRINT_HTM(60,180,500,50, this.name);
      LODOP.PREVIEW();
    }
  },
  computed: {},
  watch: {},
  mounted() {
    this.getDetails(this.$route.query.id);
  }
};
</script>

<style lang="less" scoped>
body,
td {
  font-size: 13px;
}
.bg_write {
  text-align: left !important;
  color: #000 !important;
  background: #fff;
}
</style>
